Note: For our simulations we use Matlab. Matlab only works with
discrete signals, not continuous signals, so the simulation is
not exact. Some of the things we must do in the simulation are
because we are using discrete signals, or samples of continuous
signals, and why they are done will not be obvious until you take
a class in digital signal processing.
Please follow all the guidelines for computer homework. Homework
that does not follow the guidelines will be returned without being
corrected.
Computer Homework 2
In this homework you will implement an amplitude modulation and
demodulation system and test system performance in the presence
of noise. You will modulate and demodulate a signal adding noise,
and listen to the result. Test your program using the signal sound1.wav.
The diskette should include hw3.m and sound1.wav. Make shure the
program you hand in runs independently of the hard drive, remember
that the machine you work on and the machine I use to test the
program are not the same.
For convenience, let m be the message signal, s be the modulated
signal, and m_demod be the demodulated signal.
Read in the wav file.. To read in a the wav file signal1.wav on drive a: into matlab use the command
>>[m,fs]=wavread('a:signal1.wav');
m is the name you give to the signal, and fs is the sampling frequency
used for m. Since m is a digital signal, we need to know the sampling
rate in order to hear it later.
This signal has been band limited to 3kHz. The sampling rate is
44.1kHz, so we have to use a carrier frequency smaller than 44.1k/2=22.05kHz.
Use 15kHz as the carrier frequency. You can choose any Ac, ka
and A'c you like, as long as the requirements we developed in
class are met.
Modulate the message signal to get s. Make noise with the command
>>noise=randn(size(m));
Add this noise to the modulated signal. Experiment with different noise amplitudes. For example, to make the noise 3 times larger use
>>noise=noise*3;
The noise can be made smaller in the same way. Only include one
noise amplitude in the program you hand in. I want you to find
the maximum noise that still produces an acceptable output.
Demodulate the signal. Listen to both the original sine wave and the demodulated sine wave. To listen to a signal called m in matlab use
>>sound(m,fs)
where fs is the sampling frequency.
Calculate the Signal to Noise Ratio (SNR) of the output. SNR is defined as the ratio of the power in the signal to the power in the noise. Since we have demodulated the signal, the noise in the demodulated signal is not the same noise added to the modulated signal. Assume the output signal m_demod is made up of the original signal plus additive noise as follows
m_demod = m + demod_noise. (or demod_noise = m - m_demod).
The SNR is then the power in m divided by the power in demod_noise. For random signals, we can use the variance of the signal to calculate the power. Thus,
SNR = variance(m)/variance(demod_noise). In matlab, use the var() command to calculate the variance. It is customary to measure SNR in decibels, so use
SNRdB = 20log10( variance(m)/variance(demod_noise)).
You must be careful when calculating demod_noise. It takes time
for the signal to go through the system. You must calculate this
lag, and use it when subtracting m-demod from m.
Notice that as the amplitude of the noise added is increased,
the signal to noise ratio goes down. Find the minimum signal to
noise ratio that you think is acceptable.